package bb.lanxing.net.core;

import java.io.IOException;
import okhttp3.OkHttpClient;


public abstract class ApiClientWrapper<REQ, RESP> implements ApiClient<ApiRequest, ApiResponse> {
    protected abstract ApiResponse convert(RESP response);

    protected abstract REQ convert(ApiRequest request);

    protected abstract ApiClient<REQ, RESP> getApiClient();

    @Override
    public ApiResponse execute(ApiRequest request) throws IOException {
        return convert((RESP) getApiClient().execute(convert(request)));
    }

    @Override
    public OkHttpClient getOKHttpClient() {
        return getApiClient().getOKHttpClient();
    }
}
